package com.carkeeper.system.dao;

import com.carkeeper.system.pojo.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;



/**
 * @author 周志雄
 * @version 1.0
 * @date 2020/11/24 14:41
 */
public interface RoleDao extends Mapper<Role> {

    @Delete("delete from tb_role_menu where role_id=#{id}")
    int deleteByRoleId(Long id);

    @Insert("insert into tb_role_menu values(#{menuId},#{id})")
    int insertRoleIdAndMenuId(@Param("id") Long id, @Param("menuId") Long menuId);

    @Insert("insert into tb_role(name,detail) values(#{name},#{detail})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    int insertRoleReturnId(Role role);

}
